/* -------------------------------------------------------------------------------- */
/* -- µGUI - Generic GUI module (C)Achim Döbler, 2015                            -- */
/* -------------------------------------------------------------------------------- */
// µGUI is a generic GUI module for embedded systems.
// This is a free software that is open for education, research and commercial
// developments under license policy of following terms.
//
//  Copyright (C) 2015, Achim Döbler, all rights reserved.
//  URL: http://www.embeddedlightning.com/
//
// * The µGUI module is a free software and there is NO WARRANTY.
// * No restriction on use. You can use, modify and redistribute it for
//   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
// * Redistributions of source code must retain the above copyright notice.
//
/* -------------------------------------------------------------------------------- */
#ifndef __UGUI_H
#define __UGUI_H

#include <stdlib.h>
#include "ugui_config.h"
#include "ugui_colors.h"
#if !defined(UGUI_USE_CUSTOM_THEME)
#include "ugui_theme.h"
#else
#include "ugui_theme_custom.h"
#endif

/* -------------------------------------------------------------------------------- */
/* -- TYPEDEFS                                                                   -- */
/* -------------------------------------------------------------------------------- */
typedef struct S_OBJECT UG_OBJECT;
typedef struct S_WINDOW UG_WINDOW;
typedef UG_S8 UG_RESULT;
#if defined(UGUI_USE_COLOR_RGB888)
typedef UG_U32 UG_COLOR;
#elif defined(UGUI_USE_COLOR_RGB565)
typedef UG_U16 UG_COLOR;
#elif defined(UGUI_USE_COLOR_BW)
typedef UG_U8 UG_COLOR;
#endif
#if !defined(UGUI_USE_COLOR_RGB888) && !defined(UGUI_USE_COLOR_RGB565) && !defined(UGUI_USE_COLOR_BW)
#error "You must define a color space!"
#endif
#if defined(UGUI_USE_COLOR_RGB888) && defined(UGUI_USE_COLOR_RGB565) || \
    defined(UGUI_USE_COLOR_RGB888) && defined(UGUI_USE_COLOR_BW) ||     \
    defined(UGUI_USE_COLOR_RGB565) && defined(UGUI_USE_COLOR_BW) ||     \
    defined(UGUI_USE_COLOR_RGB888) && defined(UGUI_USE_COLOR_RGB565) && defined(UGUI_USE_COLOR_BW)
#error "You must define only one color space!"
#endif
#if !defined(C_PAL_WINDOW)
#error "You must define a theme!"
#endif

/* -------------------------------------------------------------------------------- */
/* -- DEFINES                                                                    -- */
/* -------------------------------------------------------------------------------- */
/* Internal helpers */
#define UG_GetFontWidth(f) *(f + 1)
#define UG_GetFontHeight(f) *(f + 2)
#define swap(a, b)  \
   {                \
      UG_U16 t = a; \
      a = b;        \
      b = t;        \
   }

/* Sizing helpers */
#define UGUI_POS(xs, ys, w, h) xs, ys, xs + w, ys + h

/* 对齐方式定义 */
#define ALIGN_H_LEFT        (1 << 0)  // 水平左对齐
#define ALIGN_H_CENTER      (1 << 1)  // 水平居中对齐
#define ALIGN_H_RIGHT       (1 << 2)  // 水平右对齐
#define ALIGN_V_TOP         (1 << 3)  // 垂直顶部对齐
#define ALIGN_V_CENTER      (1 << 4)  // 垂直居中对齐
#define ALIGN_V_BOTTOM      (1 << 5)  // 垂直底部对齐

#define ALIGN_BOTTOM_RIGHT   (ALIGN_V_BOTTOM | ALIGN_H_RIGHT)    // 右下对齐
#define ALIGN_BOTTOM_CENTER  (ALIGN_V_BOTTOM | ALIGN_H_CENTER)   // 下居中对齐
#define ALIGN_BOTTOM_LEFT    (ALIGN_V_BOTTOM | ALIGN_H_LEFT)     // 左下对齐
#define ALIGN_CENTER_RIGHT   (ALIGN_V_CENTER | ALIGN_H_RIGHT)    // 右居中对齐
#define ALIGN_CENTER         (ALIGN_V_CENTER | ALIGN_H_CENTER)   // 居中对齐
#define ALIGN_CENTER_LEFT    (ALIGN_V_CENTER | ALIGN_H_LEFT)     // 左居中对齐
#define ALIGN_TOP_RIGHT      (ALIGN_V_TOP | ALIGN_H_RIGHT)       // 右上对齐
#define ALIGN_TOP_CENTER     (ALIGN_V_TOP | ALIGN_H_CENTER)      // 上居中对齐
#define ALIGN_TOP_LEFT       (ALIGN_V_TOP | ALIGN_H_LEFT)        // 左上对齐

/* Default IDs */
#define OBJ_ID_0 0
#define OBJ_ID_1 1
#define OBJ_ID_2 2
#define OBJ_ID_3 3
#define OBJ_ID_4 4
#define OBJ_ID_5 5
#define OBJ_ID_6 6
#define OBJ_ID_7 7
#define OBJ_ID_8 8
#define OBJ_ID_9 9
#define OBJ_ID_10 10
#define OBJ_ID_11 11
#define OBJ_ID_12 12
#define OBJ_ID_13 13
#define OBJ_ID_14 14
#define OBJ_ID_15 15
#define OBJ_ID_16 16
#define OBJ_ID_17 17
#define OBJ_ID_18 18
#define OBJ_ID_19 19

/* -------------------------------------------------------------------------------- */
/* -- FUNCTION RESULTS                                                           -- */
/* -------------------------------------------------------------------------------- */
#define UG_RESULT_FAIL -1
#define UG_RESULT_OK 0

/* -------------------------------------------------------------------------------- */
/* -- FONTS                                                                      -- */
/* -------------------------------------------------------------------------------- */

/* Font structures */
typedef enum
{
   FONT_TYPE_1BPP,
   FONT_TYPE_8BPP
} FONT_TYPE;

typedef struct
{
   FONT_TYPE font_type;
   UG_U8 is_old_font; // This exists to maintain compatibility with old fonts, as they use code page 850 instead of Unicode
   UG_U8 char_width;
   UG_U8 char_height;
   UG_U16 bytes_per_char;
   UG_U16 number_of_chars;
   UG_U16 offset_size;
   const UG_U8 *widths;
   const UG_U8 *offsets;
   const UG_U8 *data;
   UG_FONT *font;
} UG_FONT_DATA;

#ifdef UGUI_USE_UTF8
typedef UG_U16 UG_CHAR;
#else
typedef char UG_CHAR;
#endif

/* -------------------------------------------------------------------------------- */
/* -- UNIVERSAL STRUCTURES                                                       -- */
/* -------------------------------------------------------------------------------- */
/* Area structure */
typedef struct
{
   UG_S16 xs;
   UG_S16 ys;
   UG_S16 xe;
   UG_S16 ye;
} UG_AREA;

/* Text structure */
typedef struct
{
   char *str;
   UG_FONT *font;
   UG_AREA a;
   UG_COLOR fc;
   UG_COLOR bc;
   UG_U8 align;
   UG_S16 h_space;
   UG_S16 v_space;
} UG_TEXT;

/* -------------------------------------------------------------------------------- */
/* -- BITMAP                                                                     -- */
/* -------------------------------------------------------------------------------- */
/**
 * @brief 位图数据结构定义
 * @note  用于存储和管理位图图像的基本信息
 */
typedef struct
{
   const void *p;       /*!< 位图数据指针 */
   const UG_U16 width;  /*!< 位图宽度(像素) */
   const UG_U16 height; /*!< 位图高度(像素) */
   const UG_U8 bpp;     /*!< 每像素位数(bits per pixel) */
   const UG_U8 colors;  /*!< 颜色数量(仅用于调色板模式) */
} UG_BMP;

#define BMP_BPP_1 (1 << 0)
#define BMP_BPP_2 (1 << 1)
#define BMP_BPP_4 (1 << 2)
#define BMP_BPP_8 (1 << 3)
#define BMP_BPP_16 (1 << 4)
#define BMP_BPP_32 (1 << 5)
#define BMP_RGB888 (1 << 0)
#define BMP_RGB565 (1 << 1)
#define BMP_RGB555 (1 << 2)

/* -------------------------------------------------------------------------------- */
/* -- MESSAGE                                                                    -- */
/* -------------------------------------------------------------------------------- */
/**
 * @brief 消息结构体定义
 * @note  用于GUI系统中对象间通信的消息数据结构
 */
typedef struct
{
   UG_U8 type;     /*!< 消息类型 (MSG_TYPE_NONE/WINDOW/OBJECT) */
   UG_U8 id;       /*!< 消息ID,用于标识消息来源对象类型 */
   UG_U8 sub_id;   /*!< 子ID,用于标识具体的对象实例 */
   UG_U8 event;    /*!< 事件类型,表示具体的消息事件 */
   UG_OBJECT *src; /*!< 消息源对象指针 */
} UG_MESSAGE;

/* Message types */
#define MSG_TYPE_NONE 0
#define MSG_TYPE_WINDOW 1
#define MSG_TYPE_OBJECT 2

/* -------------------------------------------------------------------------------- */
/* -- TOUCH                                                                      -- */
/* -------------------------------------------------------------------------------- */
#ifdef UGUI_USE_TOUCH
/* Touch structure */
typedef struct
{
   UG_U8 state;
   UG_S16 xp;
   UG_S16 yp;
} UG_TOUCH;

#define TOUCH_STATE_PRESSED 1
#define TOUCH_STATE_RELEASED 0
#endif

/* -------------------------------------------------------------------------------- */
/* -- OBJECTS                                                                    -- */
/* -------------------------------------------------------------------------------- */
/* Object structure */
struct S_OBJECT
{
   UG_U8 state; /* object state                               */
#ifdef UGUI_USE_TOUCH
   UG_U8 touch_state; /* object touch state                         */
#endif
   void (*update)(UG_WINDOW *, UG_OBJECT *); /* pointer to object-specific update function */
   UG_AREA a_abs;                            /* absolute area of the object                */
   UG_AREA a_rel;                            /* relative area of the object                */
   UG_U8 type;                               /* object type                                */
   UG_U8 id;                                 /* object ID                                  */
   UG_U8 event;                              /* object-specific events                     */
   void *data;                               /* pointer to object-specific data            */
};

/* Currently supported objects */
#define OBJ_TYPE_NONE 0

/* Standard object events */
#define OBJ_EVENT_NONE 0
#ifdef UGUI_USE_PRERENDER_EVENT
#define OBJ_EVENT_PRERENDER 1
#endif
#ifdef UGUI_USE_POSTRENDER_EVENT
#define OBJ_EVENT_POSTRENDER 2
#endif
#ifdef UGUI_USE_TOUCH
#define OBJ_EVENT_PRESSED 3
#define OBJ_EVENT_RELEASED 4
#endif

/* Object states */
#define OBJ_STATE_FREE (1 << 0)
#define OBJ_STATE_VALID (1 << 1)
#define OBJ_STATE_BUSY (1 << 2)
#define OBJ_STATE_VISIBLE (1 << 3)
#define OBJ_STATE_ENABLE (1 << 4)
#define OBJ_STATE_UPDATE (1 << 5)
#define OBJ_STATE_REDRAW (1 << 6)
#ifdef UGUI_USE_TOUCH
#define OBJ_STATE_TOUCH_ENABLE (1 << 7)
#endif
#define OBJ_STATE_INIT (OBJ_STATE_FREE | OBJ_STATE_VALID)

#ifdef UGUI_USE_TOUCH
/* Object touch states */
#define OBJ_TOUCH_STATE_CHANGED (1 << 0)
#define OBJ_TOUCH_STATE_PRESSED_ON_OBJECT (1 << 1)
#define OBJ_TOUCH_STATE_PRESSED_OUTSIDE_OBJECT (1 << 2)
#define OBJ_TOUCH_STATE_RELEASED_ON_OBJECT (1 << 3)
#define OBJ_TOUCH_STATE_RELEASED_OUTSIDE_OBJECT (1 << 4)
#define OBJ_TOUCH_STATE_IS_PRESSED_ON_OBJECT (1 << 5)
#define OBJ_TOUCH_STATE_IS_PRESSED (1 << 6)
#define OBJ_TOUCH_STATE_INIT 0
#endif

/* -------------------------------------------------------------------------------- */
/* -- WINDOW                                                                     -- */
/* -------------------------------------------------------------------------------- */
/* Title structure */
typedef struct
{
   char *str;
   UG_FONT *font;
   UG_S8 h_space;
   UG_S8 v_space;
   UG_U8 align;
   UG_COLOR fc;
   UG_COLOR bc;
   UG_COLOR ifc;
   UG_COLOR ibc;
   UG_U8 height;
} UG_TITLE;

/* Window structure */
struct S_WINDOW
{
   UG_U8 objcnt;
   UG_OBJECT *objlst;
   UG_U8 state;
   UG_COLOR fc;
   UG_COLOR bc;
   UG_S16 xs;
   UG_S16 ys;
   UG_S16 xe;
   UG_S16 ye;
   UG_U8 style;
   UG_TITLE title;
   void (*cb)(UG_MESSAGE *);
};

/* Window states */
#define WND_STATE_FREE (1 << 0)
#define WND_STATE_VALID (1 << 1)
#define WND_STATE_BUSY (1 << 2)
#define WND_STATE_VISIBLE (1 << 3)
#define WND_STATE_ENABLE (1 << 4)
#define WND_STATE_UPDATE (1 << 5)
#define WND_STATE_REDRAW_TITLE (1 << 6)

/* Window styles */
#define WND_STYLE_2D (0 << 0)
#define WND_STYLE_3D (1 << 0)
#define WND_STYLE_HIDE_TITLE (0 << 1)
#define WND_STYLE_SHOW_TITLE (1 << 1)

/* -------------------------------------------------------------------------------- */
/* -- µGUI DRIVER                                                                -- */
/* -------------------------------------------------------------------------------- */
typedef struct
{
   void *driver;
   UG_U8 state;
} UG_DRIVER;

#define DRIVER_REGISTERED (1 << 0)
#define DRIVER_ENABLED (1 << 1)

/* Supported drivers */
#define NUMBER_OF_DRIVERS 4
#define DRIVER_DRAW_LINE 0
#define DRIVER_FILL_FRAME 1
#define DRIVER_FILL_AREA 2
#define DRIVER_DRAW_BMP 3

/* -------------------------------------------------------------------------------- */
/* -- µGUI CORE STRUCTURE                                                        -- */
/* -------------------------------------------------------------------------------- */

struct _UG_DEVICE;
typedef struct _UG_DEVICE UG_DEVICE;

typedef void (*PixelSetFunc)(UG_S16, UG_S16, UG_COLOR);
typedef void (*FlushFunc)(void);

struct _UG_DEVICE
{
   UG_S16 x_dim;
   UG_S16 y_dim;
   PixelSetFunc pset;
   FlushFunc flush;
};

typedef struct
{
   UG_DEVICE *device;
#ifdef UGUI_USE_TOUCH
   UG_TOUCH touch;
#endif
   UG_WINDOW *next_window;
   UG_WINDOW *active_window;
   UG_WINDOW *last_window;
#if defined(UGUI_USE_CONSOLE)
   struct
   {
      UG_S16 x_pos;
      UG_S16 y_pos;
      UG_S16 x_start;
      UG_S16 y_start;
      UG_S16 x_end;
      UG_S16 y_end;
      UG_COLOR fore_color;
      UG_COLOR back_color;
   } console;
#endif
   UG_FONT *font;
   UG_FONT_DATA currentFont;
   UG_U8 transparent_font;
   UG_S8 char_h_space;
   UG_S8 char_v_space;
   UG_COLOR fore_color;
   UG_COLOR back_color;
   UG_COLOR desktop_color;
   UG_U8 state;
   UG_DRIVER driver[NUMBER_OF_DRIVERS];
} UG_GUI;

#define UG_STATUS_WAIT_FOR_UPDATE (1 << 0)

#include "ugui_button.h"
#include "ugui_checkbox.h"
#include "ugui_fonts.h"
#include "ugui_image.h"
#include "ugui_progress.h"
#include "ugui_textbox.h"
/* -------------------------------------------------------------------------------- */
/* -- PROTOTYPES                                                                 -- */
/* -------------------------------------------------------------------------------- */
/* Classic functions */
UG_S16 UG_Init(UG_GUI *g, UG_DEVICE *device);
UG_S16 UG_SelectGUI(UG_GUI *g);
UG_GUI *UG_GetGUI(void);

/* 字体相关函数 */
void UG_FontSelect(UG_FONT *font);    // 选择字体
void UG_FontSetHSpace(UG_U16 s);      // 设置字体水平间距
void UG_FontSetVSpace(UG_U16 s);      // 设置字体垂直间距
void UG_FontSetTransparency(UG_U8 t); // 设置字体透明度
UG_U8 UG_FontGetTransparency(void);   // 获取字体透明度

/* 填充绘制函数 */
void UG_FillScreen(UG_COLOR c);                                                                     // 填充整个屏幕
void UG_FillFrame(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c);                          // 填充矩形框
void UG_FillRoundFrame(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_S16 r, UG_COLOR c);           // 填充圆角矩形框
void UG_FillCircle(UG_S16 x0, UG_S16 y0, UG_S16 r, UG_COLOR c);                                     // 填充圆形
void UG_FillTriangle(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_S16 x3, UG_S16 y3, UG_COLOR c); // 填充三角形

/* 线条绘制函数 */
void UG_DrawMesh(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_U16 spacing, UG_COLOR c);           // 绘制网格
void UG_DrawFrame(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c);                          // 绘制矩形框
void UG_DrawRoundFrame(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_S16 r, UG_COLOR c);           // 绘制圆角矩形框
void UG_DrawPixel(UG_S16 x0, UG_S16 y0, UG_COLOR c);                                                // 绘制像素点
void UG_DrawCircle(UG_S16 x0, UG_S16 y0, UG_S16 r, UG_COLOR c);                                     // 绘制圆形
void UG_DrawArc(UG_S16 x0, UG_S16 y0, UG_S16 r, UG_U8 s, UG_COLOR c);                               // 绘制圆弧
void UG_DrawLine(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c);                           // 绘制直线
void UG_DrawTriangle(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_S16 x3, UG_S16 y3, UG_COLOR c); // 绘制三角形

/* 文本显示函数 */
void UG_PutString(UG_S16 x, UG_S16 y, char *str);                           // 显示字符串
void UG_PutChar(UG_CHAR chr, UG_S16 x, UG_S16 y, UG_COLOR fc, UG_COLOR bc); // 显示单个字符

/* 控制台相关函数 */
#if defined(UGUI_USE_CONSOLE)
void UG_ConsolePutString(char *str);                                // 控制台输出字符串
void UG_ConsoleSetArea(UG_S16 xs, UG_S16 ys, UG_S16 xe, UG_S16 ye); // 设置控制台区域
void UG_ConsoleSetForecolor(UG_COLOR c);                            // 设置控制台前景色
void UG_ConsoleSetBackcolor(UG_COLOR c);                            // 设置控制台背景色
#endif

/* 颜色设置函数 */
void UG_SetForecolor(UG_COLOR c); // 设置前景色
void UG_SetBackcolor(UG_COLOR c); // 设置背景色

/* 屏幕尺寸获取函数 */
UG_S16 UG_GetXDim(void); // 获取屏幕宽度
UG_S16 UG_GetYDim(void); // 获取屏幕高度

/* 杂项功能函数 */
void UG_WaitForUpdate(void);                                                                                    // 等待屏幕刷新完成
void UG_Update(void);                                                                                           // 刷新屏幕显示
void UG_DrawBMP(UG_S16 xp, UG_S16 yp, UG_BMP *bmp);                                                             // 绘制位图
void UG_DrawBMP_ReplaceColor( UG_S16 xp, UG_S16 yp, UG_BMP* bmp);
#ifdef UGUI_USE_TOUCH
void UG_TouchUpdate(UG_S16 xp, UG_S16 yp, UG_U8 state); // 触摸事件更新
#endif

/* Driver functions */
void UG_DriverRegister(UG_U8 type, void *driver);
void UG_DriverEnable(UG_U8 type);
void UG_DriverDisable(UG_U8 type);

/* Internal API functions */
void _UG_PutText(UG_TEXT *txt);
UG_OBJECT *_UG_SearchObject(UG_WINDOW *wnd, UG_U8 type, UG_U8 id);
void _UG_DrawObjectFrame(UG_S16 xs, UG_S16 ys, UG_S16 xe, UG_S16 ye, UG_COLOR *p);
UG_OBJECT *_UG_GetFreeObject(UG_WINDOW *wnd);
UG_RESULT _UG_DeleteObject(UG_WINDOW *wnd, UG_U8 type, UG_U8 id);
#ifdef UGUI_USE_PRERENDER_EVENT
void _UG_SendObjectPrerenderEvent(UG_WINDOW *wnd, UG_OBJECT *obj);
#endif
#ifdef UGUI_USE_POSTRENDER_EVENT
void _UG_SendObjectPostrenderEvent(UG_WINDOW *wnd, UG_OBJECT *obj);
#endif
UG_U32 _UG_ConvertRGB565ToRGB888(UG_U16 c);

/* Window functions - 窗口函数 */
/* 基础窗口操作 */
UG_RESULT UG_WindowCreate(UG_WINDOW *wnd, UG_OBJECT *objlst, UG_U8 objcnt, void (*cb)(UG_MESSAGE *)); // 创建窗口
UG_RESULT UG_WindowDelete(UG_WINDOW *wnd);                                                            // 删除窗口
UG_RESULT UG_WindowShow(UG_WINDOW *wnd);                                                              // 显示窗口
UG_RESULT UG_WindowHide(UG_WINDOW *wnd);                                                              // 隐藏窗口
UG_RESULT UG_WindowResize(UG_WINDOW *wnd, UG_S16 xs, UG_S16 ys, UG_S16 xe, UG_S16 ye);                // 调整窗口大小
UG_RESULT UG_WindowAlert(UG_WINDOW *wnd);                                                             // 窗口警告

/* 窗口颜色设置 */
UG_RESULT UG_WindowSetForeColor(UG_WINDOW *wnd, UG_COLOR fc);             // 设置前景色
UG_RESULT UG_WindowSetBackColor(UG_WINDOW *wnd, UG_COLOR bc);             // 设置背景色
UG_RESULT UG_WindowSetTitleTextColor(UG_WINDOW *wnd, UG_COLOR c);         // 设置标题文字颜色
UG_RESULT UG_WindowSetTitleColor(UG_WINDOW *wnd, UG_COLOR c);             // 设置标题栏颜色
UG_RESULT UG_WindowSetTitleInactiveTextColor(UG_WINDOW *wnd, UG_COLOR c); // 设置非活动标题文字颜色
UG_RESULT UG_WindowSetTitleInactiveColor(UG_WINDOW *wnd, UG_COLOR c);     // 设置非活动标题栏颜色

/* 窗口标题设置 */
UG_RESULT UG_WindowSetTitleText(UG_WINDOW *wnd, char *str);            // 设置标题文字
UG_RESULT UG_WindowSetTitleTextFont(UG_WINDOW *wnd, UG_FONT *font);    // 设置标题字体
UG_RESULT UG_WindowSetTitleTextHSpace(UG_WINDOW *wnd, UG_S8 hs);       // 设置标题水平间距
UG_RESULT UG_WindowSetTitleTextVSpace(UG_WINDOW *wnd, UG_S8 vs);       // 设置标题垂直间距
UG_RESULT UG_WindowSetTitleTextAlignment(UG_WINDOW *wnd, UG_U8 align); // 设置标题对齐方式
UG_RESULT UG_WindowSetTitleHeight(UG_WINDOW *wnd, UG_U8 height);       // 设置标题栏高度

/* 窗口位置设置 */
UG_RESULT UG_WindowSetXStart(UG_WINDOW *wnd, UG_S16 xs);  // 设置窗口起始X坐标
UG_RESULT UG_WindowSetYStart(UG_WINDOW *wnd, UG_S16 ys);  // 设置窗口起始Y坐标
UG_RESULT UG_WindowSetXEnd(UG_WINDOW *wnd, UG_S16 xe);    // 设置窗口结束X坐标
UG_RESULT UG_WindowSetYEnd(UG_WINDOW *wnd, UG_S16 ye);    // 设置窗口结束Y坐标
UG_RESULT UG_WindowSetStyle(UG_WINDOW *wnd, UG_U8 style); // 设置窗口样式

/* 窗口属性获取 */
UG_COLOR UG_WindowGetForeColor(UG_WINDOW *wnd);              // 获取前景色
UG_COLOR UG_WindowGetBackColor(UG_WINDOW *wnd);              // 获取背景色
UG_COLOR UG_WindowGetTitleTextColor(UG_WINDOW *wnd);         // 获取标题文字颜色
UG_COLOR UG_WindowGetTitleColor(UG_WINDOW *wnd);             // 获取标题栏颜色
UG_COLOR UG_WindowGetTitleInactiveTextColor(UG_WINDOW *wnd); // 获取非活动标题文字颜色
UG_COLOR UG_WindowGetTitleInactiveColor(UG_WINDOW *wnd);     // 获取非活动标题栏颜色
char *UG_WindowGetTitleText(UG_WINDOW *wnd);                 // 获取标题文字
UG_FONT *UG_WindowGetTitleTextFont(UG_WINDOW *wnd);          // 获取标题字体
UG_S8 UG_WindowGetTitleTextHSpace(UG_WINDOW *wnd);           // 获取标题水平间距
UG_S8 UG_WindowGetTitleTextVSpace(UG_WINDOW *wnd);           // 获取标题垂直间距
UG_U8 UG_WindowGetTitleTextAlignment(UG_WINDOW *wnd);        // 获取标题对齐方式
UG_U8 UG_WindowGetTitleHeight(UG_WINDOW *wnd);               // 获取标题栏高度
UG_S16 UG_WindowGetXStart(UG_WINDOW *wnd);                   // 获取窗口起始X坐标
UG_S16 UG_WindowGetYStart(UG_WINDOW *wnd);                   // 获取窗口起始Y坐标
UG_S16 UG_WindowGetXEnd(UG_WINDOW *wnd);                     // 获取窗口结束X坐标
UG_S16 UG_WindowGetYEnd(UG_WINDOW *wnd);                     // 获取窗口结束Y坐标
UG_U8 UG_WindowGetStyle(UG_WINDOW *wnd);                     // 获取窗口样式

/* 窗口尺寸获取 */
UG_RESULT UG_WindowGetArea(UG_WINDOW *wnd, UG_AREA *a); // 获取窗口区域
UG_S16 UG_WindowGetInnerWidth(UG_WINDOW *wnd);          // 获取窗口内部宽度
UG_S16 UG_WindowGetOuterWidth(UG_WINDOW *wnd);          // 获取窗口外部宽度
UG_S16 UG_WindowGetInnerHeight(UG_WINDOW *wnd);         // 获取窗口内部高度
UG_S16 UG_WindowGetOuterHeight(UG_WINDOW *wnd);         // 获取窗口外部高度

#endif
